<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>drag</title>
    <link rel="stylesheet" href="./resize/resize.css">
    <style>
    .box {
        position: absolute;
        height: 50px;
        margin-bottom: 30px;
        cursor: move;
    }
    .box1 {
        top: 10px;
        width: 50px;
        background-color: red;
    }
    .box2 {
        top: 100px;
        width: 80px;
        background-color: green;
    }
    .box3 {
        top: 160px;
        width: 60px;
        background-color: yellow;
    }
    .box4 {
        top: 260px;
        width: 100px;
        background-color: gray;
    }
    </style>
</head>
<body>
    <!-- <div class="app" style="width:100px;height:100px;">
        <div class="test" style="width:100%;height:100%;"></div>
    </div> -->

    <div class="box box1"></div>
    <div class="box box2"></div>
    <div class="box box3"></div>

    <script>
    // document.querySelector('.app').addEventListener('click', (e) => {
    //     console.log(e.target.tagName, e.target.classList)
    // }, true)

    // document.addEventListener('click', (e) => {
    //     console.log(e.target.tagName, e.target.classList)
    // }, true)

    </script>

    <div class="box box4">
        <div class="resize-box">
            <div class="resize resize-line line-xt">
                <div class="line-middle-dot"></div>
            </div>
            <div class="resize resize-line line-xb">
                <div class="line-middle-dot"></div>
            </div>
            <div class="resize resize-line line-yl">
                <div class="line-middle-dot"></div>
            </div>
            <div class="resize resize-line line-yr">
                <div class="line-middle-dot"></div>
            </div>

            <div class="resize resize-dot dot-lt"></div>
            <div class="resize resize-dot dot-rt"></div>
            <div class="resize resize-dot dot-lb"></div>
            <div class="resize resize-dot dot-rb"></div>
        </div>
    </div>

    <script src='./utils.js'></script>
    <script src='./drag/drag.js'></script>
    <script src='./ref-line.js'></script>
    <script src='./resize/resize.js'></script>
    <script>
        // demo url https://think2011.net/ref-line/
        const refLine = new RefLine(),
              resize = new Resize({
                  resizeParentSelector: '.box'
              }),
              boxes = document.querySelectorAll('.box')

        new Drag({
            selector: '.box',
            downCallBack (currElem) {
                // currElem.siblings
                currElem.classList.add('curr-move')
            },
            moveCallBack (currElem) {
                refLine.check(currElem, boxes)
            },
            upCallBack () {
                refLine.uncheck()
            }
        })
    </script> 
</body>
</html>